﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using WeChatSDK.WeChatDto.Conversation.ReceivingMessage;
using WeChatSDKReceivingMessageService = WeChatSDK.WeChatServiceComponent.Conversation.ReceivingMessage.ReceivingMessageService;
namespace BCService.WeChatComponent.WeChatHandleService
{
    /// <summary>
    /// 微信处理服务
    /// </summary>
    public class WeChatHandleService : IWeChatHandleService
    {
        private readonly IConfiguration configuration;
        private readonly IWeChatMessageBase weChatMessageBase;
        public WeChatHandleService(IConfiguration configuration,IWeChatMessageBase weChatMessageBase)
        {
            this.configuration = configuration;
            this.weChatMessageBase = weChatMessageBase;
        }

        public string HandleMessage(string xmlMessage)
        {
            ReceivingMessageDto receivingMessageDto = WeChatSDKReceivingMessageService.MessageConvert(xmlMessage);
            IWeChatMessageHandle weChatMessageHandle = weChatMessageBase.GetHandle(receivingMessageDto);
            return weChatMessageHandle.HandleMessage(receivingMessageDto);
        }
    }
}
